//
// IterativeMethod.h
// Abstract base class for iterative methods.
//
// Author: Gabriel H. Barbuto (gbarbuto@dc.uba.ar)
//
#ifndef _ITERATIVE_METHOD_H_
#define _ITERATIVE_METHOD_H_

#include <cstddef>
#include <vector>

#include "TP1MetNumDLL.h"

class IterativeMethod
{
public:

	TP1METNUMDLL_API IterativeMethod(std::size_t const &iterations);

	TP1METNUMDLL_API IterativeMethod(double const &epsilon = IterativeMethod::default_epsilon(), std::size_t const &iterations = IterativeMethod::default_iterations());

	TP1METNUMDLL_API virtual double operator()(std::vector<double> const &arguments) = 0;

	TP1METNUMDLL_API inline double const &epsilon() const
	{
		return this->_epsilon;
	}

	TP1METNUMDLL_API inline void epsilon(double const &epsilon)
	{
		this->_epsilon = epsilon;
	}

	TP1METNUMDLL_API inline std::size_t const &iterations() const
	{
		return this->_iterations;
	}

	TP1METNUMDLL_API inline std::size_t const &max_iterations() const
	{
		return this->_max_iterations;
	}

	TP1METNUMDLL_API inline void max_iterations(std::size_t const &iterations)
	{
		this->_max_iterations = iterations;
	}

	TP1METNUMDLL_API static inline double default_epsilon()
	{
		return 1e-13;
	}

	TP1METNUMDLL_API static inline std::size_t default_iterations()
	{
		return 1000;
	}

protected:

	TP1METNUMDLL_API inline void iterations(std::size_t const &iterations)
	{
		this->_iterations = iterations;
	}

private:

	double _epsilon;
	std::size_t _iterations;
	std::size_t _max_iterations;
};

#endif

